package com.littlebee.storychild.ui;

import android.app.Activity;
import android.os.Bundle;

import com.zss.library.utils.LogUtils;

import cn.jpush.im.android.api.JMessageClient;
import cn.jpush.im.android.api.event.ContactNotifyEvent;

/**
 * Created by xuhuixiang on 2017/9/19.
 */

public class ContactNotifyEventReceiver  extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        JMessageClient.registerEventReceiver(this);
    }

    @Override
    protected void onDestroy() {
        JMessageClient.unRegisterEventReceiver(this);
        super.onDestroy();
    }

    public void onEvent(ContactNotifyEvent event) {
        String reason = event.getReason();
        String fromUsername = event.getFromUsername();
        String appkey = event.getfromUserAppKey();

        switch (event.getType()) {
            case invite_received://收到好友邀请
                LogUtils.i("XHX","XHX:"+fromUsername+"收到好友请求");
                break;
            case invite_accepted://对方接收了你的好友邀请
                LogUtils.i("XHX","XHX:"+fromUsername+"对方接受了你的好友请求");
                break;
            case invite_declined://对方拒绝了你的好友邀请
                LogUtils.i("XHX","XHX:"+fromUsername+"对方拒绝了你的好友请求");

                break;
            case contact_deleted://对方将你从好友中删除
                LogUtils.i("XHX","XHX:"+fromUsername+"对方删除了你的好友请求");

                break;
            default:
                break;
        }
    }
}
